package com.example.demo.api;

import com.example.demo.model.Message;
import com.example.demo.model.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

@RestController
public class MessageAPI {
    @Autowired
    private MessageMapper messageMapper;
    @GetMapping("/message")
    public Object getMessage(int sessionId){
        List<Message> messages=messageMapper.getMessagesBySessionId(sessionId);
        Collections.reverse(messages);
        return messages;
    }


}
